New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eosjs-ecc

Package Overview
Dependencies
Maintainers
2
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eosjs-ecc

Elliptic curve cryptography functions

  • 1.6.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
25K
decreased by-10.43%
Maintainers
2
Weekly downloads
 
Created
Source

NPM Build Status

Elliptic curve cryptography functions (ECC)

Private Key, Public Key, Signature, AES, Encryption / Decryption

Import

import ecc from 'eosjs-ecc'
// or
const ecc = require('eosjs-ecc')

Common API

wif

Wallet Import Format

Type: string

ecc

randomKey

Parameters

  • cpuEntropyBits number gather additional entropy from a CPU mining algorithm. Set to 0 for testing. (optional, default 128)

Examples

ecc.randomKey()

Returns wif

seedPrivate

Parameters

  • seed string any length string. This is private. The same seed produces the same private key every time. At least 128 random bits should be used to produce a good private key.

Examples

ecc.seedPrivate('secret') === wif

Returns wif

privateToPublic

Parameters

Examples

ecc.privateToPublic(wif) === pubkey

Returns pubkey

isValidPublic

Parameters

Examples

ecc.isValidPublic(pubkey) === true

Returns boolean valid

isValidPrivate

Parameters

Examples

ecc.isValidPrivate(wif) === true

Returns boolean valid

sign

Create a signature using data or a hash.

Parameters

  • data (string | Buffer)
  • privateKey (wif | PrivateKey)
  • hashData boolean sha256 hash data before signing (optional, default true)

Examples

ecc.sign('I am alive', wif)

Returns string hex signature

verify

Verify signed data.

Parameters

Examples

ecc.verify(signature, 'I am alive', pubkey) === true

Returns boolean

recover

Recover the public key used to create the signature.

Parameters

Examples

ecc.recover(signature, 'I am alive') === pubkey

Returns pubkey

sha256

Parameters

  • data (string | Buffer)
  • encoding string 'hex', 'binary' or 'base64' (optional, default 'hex')

Examples

ecc.sha256('hashme') === '02208b..'

Returns (string | Buffer) Buffer when encoding is null, or string

pubkey

EOSKey..

Type: string

Usage (Object API)

let {PrivateKey, PublicKey, Signature, Aes, key_utils, config} = require('eosjs-ecc')

// Create a new random private key
privateWif = PrivateKey.randomKey().toWif()


// Convert to a public key
pubkey = PrivateKey.fromWif(privateWif).toPublic().toString()

Browser

git clone https://github.com/EOSIO/eosjs-ecc.git
cd eosjs-ecc
npm install
npm run build
# builds: ./dist/eosjs-ecc.js
# Verify release hash
<script src=eosjs-ecc.js></script>
var ecc = eosjs_ecc
var privateWif = ecc.randomKey()
var pubkey = ecc.privateToPublic(privateWif)
console.log(pubkey)

Configure

const {config} = require('eosjs-ecc')

// Change the public key address prefix
// config.address_prefix = 'XXX'

See Config

Keywords

FAQs

Package last updated on 13 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc